﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using COM.Rights.Model;
using COM.Rights.BLL;
using System.Data;

public partial class Pages_BdOperateLog_Default : ZMPageList<BdOperateLog,BdOperateLogInfo>
{  
	#region 重写方法

    //不显示保存按纽
    protected override void InitBtnSave()
    {
        //base.InitBtnSave();
    }



    //不显示保存按纽
    protected override void  InitBtnDelete()
    {
 	     //base.InitBtnDelete();
    }
 


    protected override void InitBtnAdd()
    {
        //base.InitBtnAdd();
    }

    protected override void OnBind()
    {
        base.OnBind();

        PermUserWeb _PermUserWeb = new PermUserWeb();
        List<DBParameter> _listDBParameter = new List<DBParameter>();
        _listDBParameter.Add(new DBParameter("@TranType", "hostname"));
        _listDBParameter.Add(new DBParameter("@UID", ZASession.Account));

        IDataReader sdr = _PermUserWeb.ExecuteReader("[dbo].[mdlist_sel]", _listDBParameter, System.Data.CommandType.StoredProcedure);
        DataTable dt = new DataTable();
        dt.Load(sdr);

        ZABinder.FillList(string.Empty, ddlHostName, true, dt);
    }

    protected void btnRecover_Click(object sender, EventArgs e)
    {
        string str = "";
        foreach (string s in GetCheckedList())
        {
            str += "'" + s + "',";
        }
        str = str.Trim(',');
        if (!string.IsNullOrEmpty(str))
        {
            BdOperateLog bol = new BdOperateLog();
            bol.RecoverLog(str);
            OnGridChanged();

        }
    }

    protected void btnDelete_Click(object sender, EventArgs e)
    {
        string str = "";
        foreach (string s in GetCheckedList())
        {
            str += "'" + s + "',";
        }
        str = str.Trim(',');
        if (!string.IsNullOrEmpty(str))
        {
            BdOperateLog bol = new BdOperateLog();
            bol.Delete(str);
            OnGridChanged();

        }
    }




    protected override void OnMainGridRowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
    {
        BdOperateLog bol = new BdOperateLog();
        if (e.CommandName == "Recover") {
            bol.RecoverLog(e.CommandArgument.ToString());

        }
        else if (e.CommandName == "DeleteForEver")
        {
            bol.Delete(e.CommandArgument.ToString());

        }
        OnGridChanged();
    }

    protected override string DefaultFilter
    {
        get
        {
            return string.Format("  hostname IN ( SELECT hostname FROM permUserWeb puw(NOLOCK) WHERE puw.UID = '{0}' )", ZASession.Account);
            //return string.Format(" EXISTS( SELECT 1 FROM permUserWeb puw WHERE 1=1)");
        }
    }

    protected override int PageSize
    {
        get
        {
            //return base.PageSize;
            return StringHelper.FormatBlankStringToint(txtPageSize.Text);
        }
    }

    protected override string DefaultSortField
    {
        get
        {
            return "OperateDate";
        }
    }



	#endregion 	重写方法
}